<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<style>
			#header {
				background-color: #498af7;
			}
			#header h1 {
				color: #fff;
				font-size: 15px;
			}
			.mui-content {
				text-align: center;
			}
			#backToOrderList {
				display: block;
				width: 80%;
				height: 50px;
				margin: 10px auto 0;
				background-color: #498af7;
				line-height: 50px;
				color: #fff;
				text-decoration: none;
				border-radius: 10px;
				margin-top: 80px;
			}
			p, h5 {
				margin: 0;
			}
			.dispatch-result {
				margin-top: 40px;
			}
			#result-icon {
				display: inline-block;
				width: 80px;
				height: 80px;
				background-size: contain;
				background-repeat: no-repeat;
				background-image: url(../../images/success.svg);
			}
			#result-title {
				font-size: 14px;
				color: #666;
				margin-top: 10px;
			}
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav" id="header">
			<h1 class="mui-title">分配任务</h1>
		</header>
		<div class="mui-content">
			<div class="dispatch-result">
				<p><span id="result-icon"></span></p>
				<h5 id="result-title"></h5>
			</div>
			<a href="javascript:void(0);" id="backToOrderList">返回工单列表页面</a>
		</div>
		<script	src="../../js/mui.min.js"></script>
		<script>
			mui.plusReady(function() {
				var cv = plus.webview.currentWebview(), 
					urlPrefix = "https://bird.ioliu.cn/v1?url=";
				mui.ajax({
					url: urlPrefix + "http://hospital.xiaoweicanting.com/factory.php?m=App&c=orders&a=dispatch&factoryid=" + cv.factoryId + "&workerid=" + cv.eid + "&sid=" + cv.sid + "&uid=3&token=dfaf",
					type: "get",
					dataType: "json",
					async: true,
					success: function(response) {
						var resultIcon = document.getElementById("result-icon"),
							resultTitle = document.getElementById("result-title");
						if(response.state === "success") {
							
							resultIcon.style.backgroundImage = "url(../../images/success.svg)";
							resultTitle.innerHTML = "分配工单成功";
							
						} else {
							resultIcon.style.backgroundImage = "url(../../images/fail.svg)";
							resultTitle.innerHTML = "工单分配失败";
						}
						document.getElementById("backToOrderList").addEventListener("tap", function() {
							mui.openWindow({
								url: "../order/order.html"
							})
						}, false);
					}
				})
			})
		</script>
	</body>
</html>
